package com.rwx.reflect;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Properties;

public class Reflect09 {

    public static void main(String[] args) throws ClassNotFoundException,
            NoSuchMethodException,
            InvocationTargetException,
            InstantiationException, IllegalAccessException, NoSuchFieldException, IOException {

        Properties properties = new Properties();
        FileInputStream fileInputStream = new FileInputStream("src/com/rwx/reflect/prop/prop.prperpties");
        properties.load(fileInputStream);
        fileInputStream.close();
        System.out.println(properties);

        String classname=properties.get("classname")+"";
        String methodname=properties.get("methodname")+"";

        Class clazz=Class.forName(classname);
        Constructor con = clazz.getDeclaredConstructor();
        con.setAccessible(true);
        Object o = con.newInstance();
        System.out.println(o);

        Method getInfo = clazz.getMethod(methodname);
        getInfo.invoke(o);


    }
}
